//
//  MineAlterInfoViewController.m
//  ArtDog
//
//  Created by dllo on 16/8/30.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MineAlterInfoViewController.h"
#import "BaseTableView.h"
#import "MineAlterInfoTableCell.h"
#import "HLMacro.h"
#import "MineHomepageModel.h"
#import "MineHomepageViewController.h"

@interface MineAlterInfoViewController ()

@property (weak, nonatomic) IBOutlet BaseTableView *tableView;



@end

@implementation MineAlterInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.isFreeKeyboard = YES;
    [self setupTableView];
    [self tableViewProtocol];
    [self keyboardNoCover];
}

- (void)setupTableView
{
    [_tableView registerNib:[UINib nibWithNibName:@"MineAlterInfoTableCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"mineAlterInfoTableCell"];
}

- (void)tableViewProtocol
{
    [_tableView tableViewWithNumberOfRow:^(UITableView * _Nonnull tableView, TableViewReturnParam * _Nonnull tableViewParam) {
        tableViewParam.numberOfRow = 1;
    } andCellForRowAtIndexPath:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath, TableViewReturnParam * _Nonnull tableViewParam) {
        MineAlterInfoTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mineAlterInfoTableCell"];
        cell.model = _model;
        tableViewParam.returnCell = cell;
    } andHeightForrowAtIndexPath:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath, TableViewReturnParam * _Nonnull tableViewParam) {
        tableViewParam.heightAtRow = SCREEN_WIDTH + 120 + 150 + 2;
    }];
}


- (IBAction)backAction:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - 根据键盘高度改变tableView约束，使键盘不覆盖
- (void)keyboardNoCover
{
    __weak typeof(self) weakSelf = self;
    [self setKeyboard:^(NSNotification *noti, CGFloat height) {
        weakSelf.bottomLayout.constant = height - 44;
        weakSelf.tableView.contentOffset = CGPointMake(0, height - SCREEN_HEIGHT + 64 + SCREEN_WIDTH + 160);
        
    } andWillHide:^(NSNotification *noti) {
        weakSelf.bottomLayout.constant = 0;
        weakSelf.tableView.contentOffset = CGPointMake(0, 0);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
